package com.Collection集合.总结案例;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class ConllectionDemo {
    public static void main(String[] args) {
        Collection<Student> studentArrayList = new ArrayList<>();//创建集合
        Student student1 = new Student("周冬雨",18);//创建学生类对象
        Student student2 = new Student("黄四郎",19);//创建学生类对象

        //添加到集合中
        studentArrayList.add(student1);
        studentArrayList.add(student2);

        //遍历输出
        Iterator<Student> iterator = studentArrayList.iterator();
        while (iterator.hasNext()){
            System.out.println(iterator.next());
        }
    }
    /*结果
    Student(name=周冬雨, age=18)
    Student(name=黄四郎, age=19)

     */
}
